/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package lib;

/**
 *
 * @author felipe
 */
public class SQL {

    public String statement;

    public SQL()
    {
        this.statement = "";
    }

    public SQL select(String campos)
    {
        this.statement = "SELECT " + campos;
        return this;
    }

    public SQL selectfrom(String campos, String tabela)
    {
        this.statement = "SELECT " + campos + " FROM " + tabela;
        return this;
    }

    public SQL from ( String tabela)
    {
        this.statement += " FROM " + tabela;
        return this;
    }

    public SQL where(String condicao){
        this.statement += " WHERE " + condicao ;
        return this;
    }

    public SQL and(String condition)
    {
        this.statement += " AND " + condition.toString();
        return this;
    }

    public SQL or(String condition)
    {
        this.statement += " AND " + condition.toString();
        return this;
    }

    public SQL insert()
    {
        this.statement = "INSERT ";
        return this;
    }

    public SQL into(String tabela, String campos)
    {
        this.statement += "INTO "+ tabela+" (" + campos + ")";
        return this;
    }

    public SQL value(String value)
    {
        this.statement += " VALUE (" + value + ")";
        return this;
    }

    public SQL values(String value)
    {
        this.statement += " VALUES (" + value + ")";
        return this;
    }

    public SQL nvalues(String value)
    {
        this.statement += ",(" + value + ")";
        return this;
    }

    public SQL update(String tabela)
    {
        this.statement = "UPDATE " + tabela;
        return this;
    }

    public SQL set(String set)
    {
        this.statement += " SET " + set;
        return this;
    }

    public SQL nset(String set)
    {
        this.statement += ", " + set;
        return this;
    }

    public SQL delete(String tabela)
    {
        this.statement = "DELETE FROM " + tabela;
        return this;
    }

    @Override
    public String toString(){
        return this.statement;
    }

}
